/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.apt.updateAcc;

import com.apt.tag.Connect_DB;
import java.sql.Connection;
import java.sql.PreparedStatement;

/**
 *
 * @author Bach
 */
public class ProcessUpdate {

    public static boolean updateAccAdmin(UpdateAccAdminForm u) {
        String up = " UPDATE [Matrimony].[dbo].[Accounts] SET [User_Password] = ?,[User_Name]=? WHERE [Account_Id]=? ";
        boolean re = false;
        Connection con = null;
        PreparedStatement ps = null;
//        int accId=u.get
        String usname = null;
        String pass = null;
        int accId = 0;
        if (u != null) {
            accId = Integer.parseInt(u.getAccId());
            usname = u.getUsername();
            pass = u.getNewpass();
            
        } else {
            return false;
        }
        try {
            con = Connect_DB.getConnection();
            ps = con.prepareStatement(up);
            ps.setString(1, pass);
            ps.setString(2,usname );
            ps.setInt(3, accId);
            int i = ps.executeUpdate();
            if (i > 0) {
                re = true;
            }
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            Connect_DB.close(null, null, ps, con);
        }
        return re;
    }
}
